#pragma once

#include <string>
#include <memory>
#include <rtc_base/rtc_certificate.h>

#include "base/event_loop.h"
#include "pc/peer_connection.h"

namespace xrtc {

// 推拉流的基类    
class RtcStream {
public:
    RtcStream(EventLoop* el, PortAllocator* allocator, uint64_t uid, const std::string& stream_name, 
              bool audio, bool video, uint32_t log_id);

    virtual ~RtcStream() = default; 
    
    int start(rtc::RTCCertificate* certificate);

    uint64_t getuid() const { return m_uid; }

    virtual std::string createOffer() = 0;

    // 调用peerconnection的set_remote_sdp
    void set_remote_sdp(const std::string& sdp);

protected:
    EventLoop* m_el;
    uint64_t m_uid;
    std::string m_stream_name;
    bool m_audio;
    bool m_video;
    uint32_t m_log_id;

    std::unique_ptr<PeerConnection> m_pc;
};

} // namespace xrtc 